<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<body>
	<div id="clock">  <span class="dayss"></span>天  <span class="hours"></span>时   <span class="minutes"></span>分   <span class="seconds"></span>秒 </div>
</body>
<script type="text/javascript">
function getTimeReamin(endtime){   //剩余的秒数   
	var arr = endtime.split(/[- : \/]/),
        date = new Date(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]);
    var remainSec = (Date.parse(date) - Date.parse(new Date())) / 1000; //兼容苹果手机 
	var days=Math.floor(remainSec/(3600*24));    
	var hours=Math.floor(remainSec/3600%24);    
	var minutes=Math.floor(remainSec/60%60);    
	var seconds=Math.floor(remainSec%60);    
	return{"remainSec":remainSec,     "days":days,     "hours":hours,     "minutes":minutes,     "seconds":seconds    } 
 } 
var endtime="2017/10/1 12:30:30";
var timeid=setInterval(function () {  
	var t=getTimeReamin(endtime);  //判断时间格式  
	days= t.days>=0&& t.days<10?"0"+t.days:t.days;  hours= t.hours>=0&& t.hours<10?"0"+t.hours:t.hours;  minutes=t.minutes>=0&&t.minutes<10?"0"+t.minutes:t.minutes;  seconds=t.seconds>=0&&t.seconds<10?"0"+t.seconds:t.seconds;  //设置时间  
	$(".dayss").text(days);  $(".hours").text(hours);  $(".minutes").text(minutes);  $(".seconds").text(seconds);　　//清除定时器  
	if(t.remainSec<=0){   
	   clearInterval(timeid);
	}
},1000);
</script>
</html>
